﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

namespace WebSite_CodeMan
{
    public partial class LeaveMes :System.Web.UI.Page
    {
        protected string[] WebMes = new string[7];
        protected string strRightNote = string.Empty;
        protected string NoteTitle = string.Empty;
        protected string strWebType = "对话";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadLeave();
            }
        }

        private void GetBaseMes()
        {
            string strNID = Common.GetMes.GetRequestQuery(Request, "NID");
            NID.Value = (string.IsNullOrEmpty(strNID)) ? "-1" : strNID; 
            OleDbDataReader DataRead = BLL.WebInfo.GetWebBaseInfo("5");
            if (DataRead.HasRows)
            {
                DataRead.Read();
                WebMes[0] = DataRead["T_WebName"].ToString();
                WebMes[1] = DataRead["T_WebKey"].ToString();
                WebMes[2] = DataRead["T_WebDes"].ToString();
                WebMes[3] = DataRead["T_WebWord"].ToString();
                WebMes[4] = DataRead["T_WebLink"].ToString() + "&nbsp;<img src=\"../Images/IBCMes.gif\"/>&nbsp;" + DataRead["T_WebNumber"].ToString() + "&nbsp;" + DataRead["T_SPSSMes"].ToString();
                WebMes[5] = BaseClass.HtmlCommon.GetWebMenu("leave").ToString();
            }
            DataRead.Close();
            DataRead.Dispose();

            strRightNote = BaseClass.HtmlCommon.HtmlGetClassMes().ToString() + BaseClass.HtmlCommon.HtmlGetHotKey("20", Page) + BaseClass.HtmlCommon.HtmlGetTopNote();
            if (!string.IsNullOrEmpty(strNID))
            {
                strWebType = "评论";
                DataRead = BLL.NoteInfo.GetNoteTitleMes(strNID);
                if (DataRead.HasRows)
                {
                    DataRead.Read();
                    WebMes[6] = DataRead["T_NoteTitle"].ToString();
                    NoteTitle = "评论 <a href=\"" + DataRead["T_ClassEnName"].ToString() + "/" + DataRead["T_NoteID"].ToString() + ".html\" target=\"_blank\">" + DataRead["T_NoteTitle"].ToString() + "</a>";

                }
                DataRead.Close();
                DataRead.Dispose();
            }
            else
            {
                NoteTitle = "对话信息";
            }
        }
        private void LoadLeave()
        {
            GetBaseMes();
            string strNID = Common.GetMes.GetRequestQuery(Request, "NID");
            int PageCount = 0;
            int RecordCount = 0;
            string strWhere = ((string.IsNullOrEmpty(strNID)) ? " WHERE T_LeaveType=1 AND T_Flag=1 " : string.Format("  WHERE T_LeaveType=0  AND T_Flag=1 AND T_NoteID={0} ", strNID));
            RpLeave.DataSource = BLL.LeaveInfo.GetAllBaseLeaveInfo(PagerLeave.CurrentPageIndex, PagerLeave.PageSize, out PageCount, out RecordCount, strWhere);
            PagerLeave.RecordCount = RecordCount;
            RpLeave.DataBind();
        }

        protected void PagerLeave_PageChanged(object sender, EventArgs e)
        {
            LoadLeave();
        }
    }
}
